import {createRouter, createWebHistory} from 'vue-router'
import HomeLayout from '@/views/layouts/home/index.vue'
import CompanyLayout from '@/views/layouts/company/index.vue'
import AppLayout from '@/views/layouts/app/index.vue'

const router = createRouter({
    history: createWebHistory(import.meta.env.BASE_URL),
    routes: [
        {
            path: '/',
            name: 'index',
            component: HomeLayout,
            redirect: '/home',
            children: [
                {
                    path: '/home',
                    name: 'home',
                    component: () => import('@/views/pages/home/main/index.vue')
                },
                {
                    path: '/callback',
                    name: 'callback',
                    component: () => import('@/views/pages/home/login/callback.vue')
                }
            ]
        },
        {
            path: '/company',
            name: 'companyLayout',
            component: CompanyLayout,
            redirect: '/:companyId/desk',
            children: [
                {
                    path: '/company/:companyId/desk',
                    name: 'companyDesk',
                    component: () => import('@/views/pages/company/desk.vue')
                },
                {
                    path: '/company/:companyId/apps',
                    name: 'companyAppList',
                    component: () => import('@/views/pages/app/list.vue')
                }
            ]
        },
        {
            path: '/app',
            name: 'appDesignLayout',
            component: AppLayout,
            redirect: '/design/:companyId/:appId/datasets',
            children: [
                {
                    path: '/app/design/:companyId/:appId/domain',
                    name: 'appDesignDomain',
                    component: () => import('@/views/pages/design/domain/index.vue')
                },
                {
                    path: '/app/design/:companyId/:appId/datasets',
                    name: 'appDesignDataset',
                    component: () => import('@/views/pages/design/dataset/index.vue')
                },
                {
                    path: '/app/design/:companyId/:appId/views',
                    name: 'appDesignView',
                    component: () => import('@/views/pages/design/views/index.vue')
                },
            ]
        },

    ]
})

export default router
